<?php
/**
 * 首页 dashboard 面板数据
 * Author: lyun
 * Date: 2018/10/22
 * Created by Panxsoft.
 */


namespace App\Http\Controllers\Admin\Panx;

use App\Http\Controllers\ApiController;
use App\Http\Requests\Admin\Panx\Dashboard\DashBoardDeviceAccountRequest;
use App\Services\Assemblers\Admin\PanxDashboardService;
use Illuminate\Http\Request;

class DashboardController extends ApiController
{
    protected $panx_dashboard_service;

    /**
     * DashboardController constructor.
     */
    public function __construct()
    {
        $this->panx_dashboard_service = new PanxDashboardService();
    }

    /**
     * panx后台查看用户画像
     * @return array|\Illuminate\Http\Response
     */
    public function userCrowd()
    {
        $user_profiles = $this->panx_dashboard_service->assembleUserProfiles();
        $total_count = $user_profiles['total'];

        return $this->response(compact('user_profiles', 'total_count'));
    }

    /**
     * panx后台查看测肤统计信息
     *
     * @throws \Exception
     * @return array|\Illuminate\Http\Response
     */
    public function skinProportion()
    {
        $skin_proportion = $this->panx_dashboard_service->skinStatusProportion();

        return $this->response(compact('skin_proportion'));
    }

    /**
     * panx后台查看单品试妆统计
     * @return array|\Illuminate\Http\Response
     */
    public function assetTryOnCount()
    {
        $asset_try_on_count = $this->panx_dashboard_service->getAssetTryOnCount();

        return $this->response(compact('asset_try_on_count'));
    }

    /**
     * panx后台查看设备类型试妆统计数据
     * @return array|\Illuminate\Http\Response
     */
    public function createDevice()
    {
        $device_try_on_count = $this->panx_dashboard_service->getDeviceTryOnCount();

        return $this->response(compact('device_try_on_count'));
    }

    /**
     * panx后台查看设备试妆统计数据
     * @param DashBoardDeviceAccountRequest $request
     * @return array|\Illuminate\Http\Response
     */
    public function deviceAccountTryOnCount(DashBoardDeviceAccountRequest $request)
    {
        $device_account_try_on_count = $this->panx_dashboard_service->getDeviceAccountTryOnCount($request);

        return $this->response(compact('device_account_try_on_count', 'device_try_on_count'));
    }

    /**
     * panx后台查看客户统计信息
     * @param Request $request
     * @return array|\Illuminate\Http\Response
     */
    public function customers(Request $request)
    {
        $customer_profiles = $this->panx_dashboard_service->getCustomerProfiles($request);

        return $this->response($customer_profiles);
    }

}
